'''
发送post请求，参数在请求体中
1. 表单格式的参数
2. json格式的参数
'''

import requests

# 登录接口
host = "http://192.168.124.16:8088/"
url = host + "/futureloan/mvc/api/member/login"
cs = {"mobilephone": "18012345678", "pwd": "123456"}
r = requests.post(url, data=cs)
print(r.text)
print(r.request.headers)  # 请求头，content-type：application/x-www-form-urlencoded  表单格式

print("=================================")

r = requests.post(url, json=cs)
print(r.text)
print(r.request.headers)  # 请求头，content-type：application/json   json格式的参数

# 具体用data还是用json传参，要看接口是如何实现的，具体可以问开发人员。

# text/html  html文本
# text/pain   纯文本
# text/javascript  js

# 脚本发出去的请求，'User-Agent': 'python-requests/2.25.1',
# 通过设置User-Agent伪装成是浏览器发出去的请求。
print("=================================")
# value从fiddler中拷贝
hds = {
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36"}
r = requests.post(url, data=cs, headers=hds)
print(r.text)
print(r.request.headers)

print("=================================")
hds = {"User-Agent": "hahahahahahahaha"}
r = requests.post(url, data=cs, headers=hds)
print(r.text)
print(r.request.headers)

# requests.put()
# requests.delete()
